package org.example.tcp;

import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;

import java.io.Serializable;
import java.io.UnsupportedEncodingException;
import java.net.InetAddress;
import java.net.Socket;
import java.nio.charset.StandardCharsets;
import java.util.Scanner;

public class TcpData implements Serializable {
    private static final long serialVersionUID = 123456789L;

    private String source;//账号
    private String destination = "all";//当值为all时为广播,当值为down时为断开连接
    private String message;
    private InetAddress inetAddress;
    private int port;
    public TcpData(){};

    public TcpData(String source, String destination, String message,InetAddress inetAddress,int port) {
        this.source = source;
        this.destination = destination;
        this.message = message;
        this.inetAddress = inetAddress;
        this.port = port;
    }

    public int getPort() {
        return port;
    }

    public void setPort(int port) {
        this.port = port;
    }

    public InetAddress getInetAddress() {
        return inetAddress;
    }

    public void setInetAddress(InetAddress inetAddress) {
        this.inetAddress = inetAddress;
    }

    public String getSource() {
        return source;
    }

    public void setSource(String source) {
        this.source = source;
    }

    public String getDestination() {
        return destination;
    }

    public void setDestination(String destination) {
        this.destination = destination;
    }


    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    @Override
    public String toString() {
        return "TcpData{" +
                "source='" + source + '\'' +
                ", destination='" + destination + '\'' +
                ", message='" + message + '\'' +
                ", inetAddress=" + inetAddress +
                ", port=" + port +
                '}';
    }
}
